const result = require('./handle')
const abnormal = async(ctx,next) => {
    try {
        await next()
    } catch (error) {
        const isResult = error instanceof result
        if (isResult) {
            ctx.body = {
                msg:error.msg
            }
            ctx.status = error.code
        }else{
            ctx.body = {
                msg:'unknow error'
            }
            ctx.status = error.code
        }
    }
}
module.exports = abnormal